import shutil
import subprocess
import sys
import time

# 检查操作系统类型
if sys.platform == "win32":
    pyecharts_path = "C:\\Users\\Franciz\\AppData\\Roaming\\Python\\Python39\\site-packages\\pyecharts;"
    dist_path = "D:\\WorkSpace\\SelfTools"
    echart_path = "./echart;"
else:
    pyecharts_path = "/usr/local/lib/python3.9/site-packages/pyecharts:"
    dist_path = "./dist"
    echart_path = "./echart:"

args = [
    'pyinstaller',
    '-n', 'monitx',
    '-F',
    '-i', './ico/letter-m.ico',
    './main.py',
    '-p', './monit',
    '-p', './echart',
    '--add-data', f'{pyecharts_path}pyecharts',
    '--add-data', f'{echart_path}echart',
    f'--distpath={dist_path}'
]

# 将参数转换为命令行字符串
command = " ".join(args)
# 执行命令行
subprocess.run(command, shell=True)
time.sleep(2)
shutil.rmtree('./build')
